"use strict"
//查询在线信息
const mvc = require("cosjs.mvc");
exports.query = async function () {
    const sid = this.get('sid', 'int');
    const id = this.get('id', 'string');
    let item = mvc.model.mongo('active', sid);
    let option = { "multi": true, "dataType": "array", "limit": 300000, 'batchSize': 3000 };
    let query = { 'id': id };
    let ret = await item.find(query, option);
    let result = {}
    let coll = [];
    for (let i = 0; i < ret.length; ++i) {
        let val = ret[i].val;
        for (let i = 0; i < 30; ++i) {
            if (val[i]) {
                if (!result[i]) {
                    result[i] = { 'id': i, 'num': 0 };
                    coll.push(result[role.lv]);
                }
                result[i].num++;
            }
        }
    }

    let roleModel = mvc.model.mongo('role', sid);
    let roleNum = await roleModel.count({});
    return { 'coll': coll, 'roleNum': roleNum };
}